package com.dhkj.circle.ui;

import android.app.Application;
import android.os.Handler;


import com.jiongbull.jlog.Logger;
import com.jiongbull.jlog.constant.LogLevel;
import com.jiongbull.jlog.constant.LogSegment;
import com.jiongbull.jlog.util.TimeUtils;
import com.qmuiteam.qmui.arch.QMUISwipeBackActivityManager;
//import com.tencent.bugly.Bugly;

import java.util.ArrayList;
import java.util.List;

public class AppContext extends Application {

    private static AppContext instance;
    public static Logger sLogger;

    public static AppContext getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        // TODO Auto-generated method stub
        super.onCreate();

//        DatebaseHelper databaseHelper = new DatebaseHelper(AppContext.getInstance(), Const.DATABASE_NAME, null, Const.DATABASE_VERSION);

        //使用腾讯bugly功能SDK包
//        CrashReport.initCrashReport(getApplicationContext(), "4f6673ecbe", true);
//        Bugly.init(getApplicationContext(), "4f6673ecbe", true);
        instance = this;
        QMUISwipeBackActivityManager.init(this);
        List<String> logLevels = new ArrayList<>();
        logLevels.add(LogLevel.ERROR);
        logLevels.add(LogLevel.WTF);
        logLevels.add(LogLevel.VERBOSE);
        logLevels.add(LogLevel.INFO);
        logLevels.add(LogLevel.JSON);
        logLevels.add(LogLevel.DEBUG);
        sLogger = Logger.Builder.newBuilder(getApplicationContext(), "scj")
                /* 下面的属性都是默认值，你可以根据需求决定是否修改它们. */
                .setDebug(true)
                .setWriteToFile(true)
                .setLogDir("scj")
                .setLogPrefix("")
                .setLogSegment(LogSegment.TWELVE_HOURS)
                .setLogLevelsForFile(logLevels)
                .setZoneOffset(TimeUtils.ZoneOffset.P0800)
                .setTimeFormat("yyyy-MM-dd HH:mm:ss")
                .setPackagedLevel(0)
                .setStorage(null)
                .build();
        handler.postDelayed(runnable, 2000);//每两秒执行一次runnable.
    }

    Handler handler=new Handler();
    Runnable runnable=new Runnable() {
        @Override
        public void run() {
            // TODO Auto-generated method stub
            //要做的事情
            handler.postDelayed(this, 2000);
        }
    };
    public static final int NETTYPE_WIFI = 0x01;
    public static final int NETTYPE_CMWAP = 0x02;
    public static final int NETTYPE_CMNET = 0x03;

    public static final int PAGE_SIZE = 20;//默认分页大小
    private static final int CACHE_TIME = 10 * 60000;//缓存失效时间

    public static Logger getLogger() {
        return sLogger;
    }


}






